home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Controls
/
Visual Basic Controls.iso
/
vbcontrol
/
axcool
/
clspnttl.cls
< prev
next >
Wrap
Text File
|
1998-10-22
|
44KB
|
968 lines
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "PaintEffects"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Description = "Provides methods for painting transparent and disabled looking images."
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
' MultiUse = -1 'True
' Persistable = 0 'NotPersistable
' DataBindingBehavior = 0 'vbNone
' DataSourceBehavior = 0 'vbNone
' MTSTransactionMode = 0 'NotAnMTSObject
'End
Option Explicit
' ------------------------------------------------------------------------
' Copyright ⌐ 1997 Microsoft Corporation. All rights reserved.
'
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files (and/or any modified version) in any way
' you find useful, provided that you agree that Microsoft has no warranty,
' obligations or liability for any Sample Application Files.
' ------------------------------------------------------------------------
'-------------------------------------------------------------------------
'This class provides methods needed for painting masked bitmaps and
'disabled or embossed bitmaps and icons
'-------------------------------------------------------------------------
Private m_hpalHalftone As Long 'Halftone created for default palette use
'-------------------------------------------------------------------------
'Purpose: Creates a disabled-appearing (grayed) bitmap, given any format of
' input bitmap.
'In:
' [hdcDest]
' Device context to paint the picture on
' [xDest]
' X coordinate of the upper left corner of the area that the
' picture is to be painted on. (in pixels)
' [yDest]
' Y coordinate of the upper left corner of the area that the
' picture is to be painted on. (in pixels)
' [Width]
' Width of picture area to paint in pixels. Note: If this value
' is outrageous (i.e.: you passed a forms ScaleWidth in twips
' instead of the pictures' width in pixels), this procedure will
' attempt to create bitmaps that require outrageous
' amounts of memory.
' [Height]
' Height of picture area to paint in pixels. Note: If this
' value is outrageous (i.e.: you passed a forms ScaleHeight in
' twips instead of the pictures' height in pixels), this
' procedure will attempt to create bitmaps that require
' outrageous amounts of memory.
' [picSource]
' Standard Picture object to be used as the image source
' [xSrc]
' X coordinate of the upper left corner of the area in the picture
' to use as the source. (in pixels)
' Ignored if picSource is an Icon.
' [ySrc]
' Y coordinate of the upper left corner of the area in the picture
' to use as the source. (in pixels)
' Ignored if picSource is an Icon.
' [clrMask]
' Color of pixels to be masked out
' [clrHighlight]
' Color to be used as outline highlight
' [clrShadow]
' Color to be used as outline shadow
' [hPal]
' Handle of palette to select into the memory DC's used to create
' the painting effect.
' If not provided, a HalfTone palette is used.
'-------------------------------------------------------------------------
Public Sub PaintDisabledStdPic(ByVal hdcDest As Long, _
ByVal xDest As Long, _
ByVal yDest As Long, _
ByVal Width As Long, _
ByVal Height As Long, _
ByVal picSource As StdPicture, _
ByVal xSrc As Long, _
ByVal ySrc As Long, _
Optional ByVal clrMask As OLE_COLOR = vbWhite, _
Optional ByVal clrHighlight As OLE_COLOR = vb3DHighlight, _
Optional ByVal clrShadow As OLE_COLOR = vb3DShadow, _
Optional ByVal hPal As Long = 0)
Attribute PaintDisabledStdPic.VB_Description = "Paints a disabled appearing image (embossed) given a source picture object."
Dim hDcSrc As Long 'HDC that the source bitmap is selected into
Dim hbmMemSrcOld As Long
Dim hbmMemSrc As Long
Dim udtRect As RECT
Dim hbrMask As Long
Dim lMaskColor As Long
Dim hDcScreen As Long
Dim hPalOld As Long
'Verify that the passed picture is not nothing
If picSource Is Nothing Then GoTo PaintDisabledDC_InvalidParam
Select Case picSource.Type
Case vbPicTypeBitmap
'Select passed picture into an HDC
hDcScreen = GetDC(0&)
'Validate palette
If hPal = 0 Then
hPal = m_hpalHalftone
End If
hDcSrc = CreateCompatibleDC(hDcScreen)
hbmMemSrcOld = SelectObject(hDcSrc, picSource.handle)
hPalOld = SelectPalette(hDcSrc, hPal, True)
RealizePalette hDcSrc
'Draw the bitmap
PaintDisabledDC hdcDest, xDest, yDest, Width, Height, hDcSrc, xSrc, ySrc, clrMask, clrHighlight, clrShadow, hPal
SelectObject hDcSrc, hbmMemSrcOld
SelectPalette hDcSrc, hPalOld, True
RealizePalette hDcSrc
DeleteDC hDcSrc
ReleaseDC 0&, hDcScreen
Case vbPicTypeIcon
'Create a bitmap and select it into a DC
hDcScreen = GetDC(0&)
'Validate palette
If hPal = 0 Then
hPal = m_hpalHalftone
End If
hDcSrc = CreateCompatibleDC(hDcScreen)
hbmMemSrc = CreateCompatibleBitmap(hDcScreen, Width, Height)
hbmMemSrcOld = SelectObject(hDcSrc, hbmMemSrc)
hPalOld = SelectPalette(hDcSrc, hPal, True)
RealizePalette hDcSrc
'Draw Icon onto DC
udtRect.Bottom = Height
udtRect.Right = Width
OleTranslateColor clrMask, 0&, lMaskColor
SetBkColor hDcSrc, lMaskColor
hbrMask = CreateSolidBrush(lMaskColor)
FillRect hDcSrc, udtRect, hbrMask
DeleteObject hbrMask
DrawIcon hDcSrc, 0, 0, picSource.handle
'Draw Disabled image
PaintDisabledDC hdcDest, xDest, yDest, Width, Height, hDcSrc, 0&, 0&, clrMask, clrHighlight, clrShadow, hPal
'Clean up
SelectPalette hDcSrc, hPalOld, True
RealizePalette hDcSrc
DeleteObject SelectObject(hDcSrc, hbmMemSrcOld)
DeleteDC hDcSrc
ReleaseDC 0&, hDcScreen
Case Else
GoTo PaintDisabledDC_InvalidParam
End Select
Exit Sub
PaintDisabledDC_InvalidParam:
'Error.Raise giINVALID_PICTURE
Exit Sub
End Sub
'-------------------------------------------------------------------------
'Purpose: Creates a disabled-appearing (grayed) bitmap, given any format of
' input bitmap.
'In:
' [hdcDest]
' Device context to paint the picture on
' [xDest]
' X coordinate of the upper left corner of the area that the
' picture is to be painted on. (in pixels)
' [yDest]
' Y coordinate of the upper left corner of the area that the
' picture is to be painted on. (in pixels)
' [Width]
' Width of picture area to paint in pixels. Note: If this value
' is outrageous (i.e.: you passed a forms ScaleWidth in twips
' instead of the pictures' width in pixels), this procedure will
' attempt to create bitmaps that require outrageous
' amounts of memory.
' [Height]
' Height of picture area to paint in pixels. Note: If this
'